# 作业：
# 1, 操作
# 业务1：登录->用户分组—>添加分组->删除分组
import time, os
from faker import Faker
fake = Faker()
add_name = fake.name
from selenium import webdriver
from selenium.webdriver.common.by import By

option = webdriver.ChromeOptions()
option.add_experimental_option("detach", True)
bro = webdriver.Chrome(options=option)

bro.get("http://60.205.190.66:8899/admin/login")
bro.maximize_window()
# user 用户名
input_user_name=bro.find_element(By.XPATH,"//*[@id='app']/div/div/div[2]/form/div[1]/div/div[1]/input")
input_user_name.send_keys("admin")
# password 密码
input_user_password = bro.find_element(By.XPATH,"/html/body/div[1]/div/div/div[2]/form/div[2]/div/div[1]/input")
input_user_password.send_keys("920509")
# Code 验证码
input_code = bro.find_element(By.XPATH,"/html/body/div[1]/div/div/div/form/div[3]/div/div[1]/div/input")
input_code.send_keys("0")
# login 登录
input_login = bro.find_element(By.XPATH,"/html/body/div[1]/div/div/div/form/div[4]/div/button")
input_login.click()
# User_grouping 用户分组
time.sleep(2)
input_group = bro.find_element(By.XPATH,"//*[@id='app']/div/div[1]/div[1]/div/ul/li[4]/div")
input_group.click()
time.sleep(1)
input_group = bro.find_element(By.XPATH,"/html/body/div[1]/div/div[1]/div[1]/div/ul/li[4]/ul/li[2]/span")
input_group.click()
# 添加用户分组
time.sleep(1)
input_group = bro.find_element(By.XPATH,"//*[@id='app']/div/div[2]/div[2]/div/div[2]/div/div[2]/div/div[1]/div/button")
input_group.click()
# 分组名称
input_code = bro.find_element(By.XPATH,"/html/body/div[1]/div/div/div/form/div[3]/div/div[1]/div/input")
input_code.send_keys("add_name")


# 业务2：登录->客服->客服话术->添加话术->删除话术

# 业务3：登录->商品->商品分类->添加分类->删除分类
# 2、使用pytest框架做selenium自动化测试，配合allure生成测试报告
# 3、对错误的地方， 加上截图留存到本地
# 4、至少用三种定位方式，CRMEB登录做下解耦
# 5、QQ音乐用密码登录成功：https://y.qq.com/




